#include "Config.h"

#include <QSettings>
#include <QDebug>

Config * Config::m_instance = 0;


Config::Config()
{
    QSettings settings("Steam2Fb","Steam2Fb");
    settings.beginGroup("config");
    m_steamId = settings.value("steamId","").toString();
    m_saveDir = settings.value("saveDir","").toString();
    m_oAuthToken = settings.value("fbToken","").toString();

    settings.endGroup();

}

void Config::save()
{

    qDebug() << m_steamId << " " << m_saveDir << " " << m_oAuthToken;

    QSettings settings("Steam2Fb","Steam2Fb");
    settings.beginGroup("config");
    settings.setValue("steamId", m_steamId);
    settings.setValue("saveDir", m_saveDir);
    settings.setValue("fbToken", m_oAuthToken);
    settings.endGroup();
}

Config * Config::getInstance()
{
    if (!m_instance)
        m_instance = new Config();

    return m_instance;
}

const QString& Config::steamId() const
{
    return m_steamId;
}

void Config::setSteamId(const QString &steamId)
{
    m_steamId = steamId;
}

const QString& Config::saveDir() const
{
    return m_saveDir;
}

void Config::setSaveDir(const QString &saveDir)
{
    m_saveDir = saveDir;
}

const QString& Config::oAuthToken() const
{
    return m_oAuthToken;
}

void Config::setOAuthToken(const QString &token)
{
    m_oAuthToken = token;
}

